package com.logic.saas.service.applicationmodules;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.logic.saas.persistence.AppModuleMapper;
import com.logic.saas.pojo.Ps;
import com.logic.saas.pojo.SaasApplication;
import com.logic.saas.pojo.SaasModule;
import com.logic.saas.service.BaseService;
import com.logic.saas.util.AddLog;

@Service
public class AppModuleService extends BaseService {

	@Autowired
	private AppModuleMapper appModuleMapper;

	public List<SaasApplication> findAllAppModules() throws Exception {
		List<SaasApplication> apps;
		apps = appModuleMapper.findAllAppModules(new Ps());
		return apps;
	}
	
	/**
	 * 根据id集合查询对应的module 的对象集合
	 * @param ids
	 * @return List<SaasModule>
	 */
	public List<SaasModule> findModulesByIds(String[] ids){
		List<SaasModule> modules = null;
		if(ids != null){
			Map<String, Object> paramMap = new HashMap<String, Object>();
			String idsStr = "";
			for(String id:ids){
				idsStr += id;
			}
			paramMap.put("ids", idsStr);
			modules = appModuleMapper.findModuleById(new Ps(paramMap));
		}else{
			AddLog.addToLog(this.getClass(), AddLog.INFO, "modules id is null");
		}
		return modules;
	}
	
}
